package o;

import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import com.huawei.gamebox.plugin.gameservice.bean.GetGamePlayerInfoResp;
import com.huawei.gamebox.plugin.gameservice.db.tables.GameSubAcctRecord;
import java.util.List;

public class ezp {
    private static ezp ˏ;

    static class b implements IServerCallBack {
        private b() {
        }

        public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
        }

        public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
        }
    }

    public static synchronized ezp ˊ() {
        ezp o_ezp;
        synchronized (ezp.class) {
            if (ˏ == null) {
                ˏ = new ezp();
            }
            o_ezp = ˏ;
        }
        return o_ezp;
    }

    public void ˋ(final GameInfo gameInfo, final String str, final fad o_fad) {
        if (o_fad == null || gameInfo == null) {
            Logger.e("GamePlayerInfoManager", "the params is null when call the method [getPlayerInfo]");
        } else {
            new fac(str, o_fad).ˎ(gameInfo, new b(this) {
                final /* synthetic */ ezp ॱ;

                public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
                    if (Logger.ˎ()) {
                        Logger.ˏ("GamePlayerInfoManager", "handle the response of [getGamePlayerInfo]");
                    }
                    if (responseBean == null) {
                        Logger.e("GamePlayerInfoManager", "get player info response is null");
                    } else if (responseBean instanceof GetGamePlayerInfoResp) {
                        GetGamePlayerInfoResp getGamePlayerInfoResp = (GetGamePlayerInfoResp) responseBean;
                        if (getGamePlayerInfoResp.playerInfo_ == null) {
                            if (Logger.ˎ()) {
                                Logger.ˏ("GamePlayerInfoManager", "the player info is null");
                            }
                            this.ॱ.ˊ(gameInfo);
                            return;
                        }
                        getGamePlayerInfoResp.playerInfo_.ʼ(this.ॱ.ˏ(getGamePlayerInfoResp.playerInfo_.ॱ(), getGamePlayerInfoResp.playerInfo_.ˏ(), gameInfo.getAppId()));
                        try {
                            o_fad.ˋ(str, getGamePlayerInfoResp.toJson());
                        } catch (Throwable e) {
                            Logger.ˋ("GamePlayerInfoManager", "respond the get player info exception", e);
                        }
                        this.ॱ.ˊ(gameInfo);
                    } else {
                        Logger.e("GamePlayerInfoManager", "get player info response is invalid");
                    }
                }
            });
        }
    }

    private String ˏ(String str, String str2, String str3) {
        List<GameSubAcctRecord> ॱ = ezg.ॱ().ॱ(str, str3);
        if (ॱ == null || ॱ.size() <= 0) {
            return "";
        }
        for (GameSubAcctRecord gameSubAcctRecord : ॱ) {
            if ((dof.ॱ(str2) || "0".equals(str2) || str2.equals(str)) && gameSubAcctRecord.ˋ() != null && gameSubAcctRecord.ˋ().equals(str) && "".equals(gameSubAcctRecord.ॱ())) {
                if (Logger.ˎ()) {
                    Logger.ˏ("GamePlayerInfoManager", "the last login time:" + gameSubAcctRecord.ˎ());
                }
                return gameSubAcctRecord.ˎ();
            } else if (gameSubAcctRecord.ॱ() != null && gameSubAcctRecord.ॱ().equals(str2)) {
                if (Logger.ˎ()) {
                    Logger.ˏ("GamePlayerInfoManager", "the last login time:" + gameSubAcctRecord.ˎ());
                }
                return gameSubAcctRecord.ˎ();
            }
        }
        return "";
    }

    private void ˊ(GameInfo gameInfo) {
        String ˏ = ezq.ˏ().ˏ(gameInfo.getPackageName());
        String ˊ = ezq.ˏ().ˊ(gameInfo.getPackageName());
        String appId = gameInfo.getAppId();
        GameSubAcctRecord gameSubAcctRecord = new GameSubAcctRecord();
        gameSubAcctRecord.ˏ(ˏ);
        gameSubAcctRecord.ˋ(ˊ);
        gameSubAcctRecord.ˊ(appId);
        gameSubAcctRecord.ˎ(String.valueOf(System.currentTimeMillis()));
        long ˋ = ezg.ॱ().ˋ(gameSubAcctRecord);
        if (Logger.ˎ()) {
            Logger.ˏ("GamePlayerInfoManager", "update the login time to db, the result:" + ˋ);
        }
    }
}
